package org.hackystat.ui.projectviewer.gwt.server.etl;

import java.util.Date;
import java.util.TreeMap;

import org.hackystat.telemetry.service.resource.chart.jaxb.TelemetryPoint;
import org.hackystat.telemetry.service.resource.chart.jaxb.TelemetryStream;

/**
 * The time series.
 * 
 * @author Pavel Senin.
 * 
 */
public class Series {

  private TreeMap<Date, DataPoint> data;

  /**
   * Creates a new series.
   * 
   * @param dataStream The telemetry stream to parse.
   */
  public Series(TelemetryStream dataStream) {
    this.data = new TreeMap<Date, DataPoint>();
    for (TelemetryPoint p : dataStream.getTelemetryPoint()) {
      data.put(p.getTime().toGregorianCalendar().getTime(), new DataPoint(p.getTime()
          .toGregorianCalendar().getTime(), p.getValue()));
    }
  }

  /**
   * Reports the series.
   * 
   * @return The stored series.
   */
  public TreeMap<Date, DataPoint> getSeries() {
    return this.data;
  }

}
